//
//  HHSideslipView.m
//  Flower
//
//  Created by 花花 on 2016/12/12.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHSideslipView.h"

@implementation HHSideslipView
- (instancetype)initWithsideslipButtons:(NSArray<HHSideslipButton *> *)sideslipButtons height:(CGFloat)height;{
    if (self = [super init]) {
        
        CGFloat btnX = 0.f;
        CGFloat allBtnWidth = 0.f;
        // 为每个按钮设置frame, 同时计算好所有的按钮的宽度之和, 作为swipeView的宽度
        // 注意这里是反向遍历添加的
        for (HHSideslipButton *button in [sideslipButtons reverseObjectEnumerator]) {
            [self addSubview:button];
            
            button.frame = CGRectMake(btnX, 0, button.bounds.size.width, height);
            btnX += button.bounds.size.width;
            allBtnWidth += button.bounds.size.width;
        }
        // 设置frame 宽高有效, x, y在swipeTableViewCell中还会相应的调整
        self.frame = CGRectMake(0.f, 0.f, allBtnWidth, height);
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;


}

@end
